/*
 * @Description:
 * @Author: your name
 * @version:
 * @Date: 2024-01-25 09:18:33
 * @LastEditors: your name
 * @LastEditTime: 2024-01-25 10:46:41
 */
const vetrixShader = /*glsl*/ `
void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {
    // 从顶点传法向量到片元
    v_normalMC=vsInput.attributes.normalMC;
}
`;

const fragmentShader = /*glsl*/ `
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
    // 获取模型坐标
    vec3 positionMC=fsInput.attributes.positionMC;
    // 图片的宽高
    float width=40.0;
    float height=40.0;
    // 判断是否楼顶,如果z轴与当前片元法向量的夹角余弦大于0.95，近似认为是0度
    if(dot(vec3(0.,1.,0.),v_normalMC)>0.95){
        material.diffuse=vec3(0.0654,0.108,0.333);
    }else{
        // 获取到图片的uv坐标
        float textureX=mod(positionMC.x,width)/width;
        float textureY=mod(positionMC.y,height)/height;
        // 通过texture2D，进行贴图
        vec3 nightRGB=texture2D(u_NightTexture,vec2(textureX,textureY)).rgb;
        material.diffuse=nightRGB;
    }
}
`;

export default { vetrixShader, fragmentShader };
